/**
 * 
 */
package simulation;

import java.util.ArrayList;

import common.Stat;

/**
 * @author vladimir
 * 
 */
public class CorrTime_discrete {
	int Correlation_Length = 0;
	int[][] neighbors;
	int L = -1;
	double J = 0;
	double B = 0;
	double T = -1;
	Lattice_discrete Lat;
	int mcs = 40000;

	public CorrTime_discrete(int[][] neighbors, double J, int L, double B,
			double T, String modelName) {
		this.neighbors = neighbors;
		this.L = L;
		this.J = J;
		this.B = B;
		this.T = T;
		ArrayList<Double> E = Simlation();
		this.Correlation_Length = Stat.corLen(E);
		if (this.Correlation_Length > 300) {
			this.Correlation_Length = 300;
		}
	}

	// here we do simulation and return Magnetization square value
	private ArrayList<Double> Simlation() {
		int ThermalMCS = 20000;
		this.Lat = new Lattice_discrete(this.neighbors, this.J, this.L, this.B,
				this.T);
		ArrayList<Double> tE = new ArrayList<Double>();
		// start loop for sweeps
		for (int sweep = 0; sweep <= this.mcs; sweep++) {
			// update lattice
			Lat.update();
			if (sweep > ThermalMCS) {
				// record data at each appropriate sweep
				// int M = Lat.M();
				tE.add(Lat.Energy());
			}
		}
		return tE;
	}

	public int SweepStep() {
		return this.Correlation_Length;
	}

	public int MCS() {
		return 10000 * this.Correlation_Length;
	}

	public int ThermalMCS() {
		return 500 * this.Correlation_Length;
	}

}
